package com.topscore.uke.mvp.presenters;

import com.squareup.timessquare.MonthView;
import com.topscore.uke.entities.HomeBannerInfo;
import com.topscore.uke.mvp.contractors.GetHomePageBannerContractor;
import com.topscore.uke.mvp.model.GetHomePageBannerModel;
import com.topscore.uke.network.BaseResponse;
import com.topscore.uke.ui.loadsir_callback.ErrorCallBack;
import com.topscore.uke.ui.loadsir_callback.LoadingCallBack;

import java.util.List;

/**
 * Created by 71468 on 2018/3/21.
 */

public class GetHomeBannerPresenter implements GetHomePageBannerContractor, GetHomePageBannerContractor.Presenter {

    private Model mModel;

    public GetHomeBannerPresenter() {
        mModel = new GetHomePageBannerModel();
    }

    @Override
    public void getBannerInfo(GetHomePageBannerContractor.View view) {
        view.getLoadService().showCallback(LoadingCallBack.class);
        mModel.getBanner(new CallBack() {
            @Override
            public void onGetBannerSuccess(BaseResponse<List<HomeBannerInfo>> response) {
                view.onGetBannerInfoSuccess(response.getData());
            }

            @Override
            public void onError(int errorCode, String errorMessage) {
                ((ErrorCallBack) view.getErrorCallBack()).setMessage(errorMessage);
                view.getLoadService().showCallback(ErrorCallBack.class);
            }

            @Override
            public void onComplete() {
                view.getLoadService().showSuccess();
            }
        });
    }
}
